package com.dongge.service;

import com.dongge.dao.InformationDao;
import com.dongge.entity.Information;
import com.dongge.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by dongge on 16/7/31.
 */
@Service("informationService")
//@Transactional
public class InformationServiceImpl implements InformationService{

    @Autowired
    private InformationDao informationDao;

    @Autowired
    private UserService userService;

    public long save(String content,User user){
//        User user = userService.getUserById(userId);
        Information information = new Information();
        information.setContent(content);
        information.setUser(user);
        return  informationDao.save(information);
    }

    public int update(long id,String content,User user){
        Information information = new Information();
        information.setContent(content);
        information.setId(id);
        information.setUser(user);
        return informationDao.update(information);
    }

    public List<Information> getInformations(){
        return informationDao.getInformations();
    }

    public Information get(long id){
        return informationDao.get(id);
    }

    public int delete(long id){

        return informationDao.delete(id);
    }
}
